package com.anjiebang.conf;

import org.springframework.boot.bind.RelaxedPropertyResolver;
import org.springframework.context.EnvironmentAware;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * Druid的DataResource配置类
 * Created by laiyanlin on 2018/4/8.
 */
@Configuration
@EnableTransactionManagement
public class DruidDataSourceConfig implements EnvironmentAware {

    /**
     * 注意重写的方法 setEnvironment 是在系统启动的时候被执行。
     */
    private RelaxedPropertyResolver propertyResolver;

    /**
     * spring boot 配置
     * 注意重写的方法 setEnvironment 是在系统启动的时候被执行。
     */
    @Override
    public void setEnvironment(Environment env) {
        this.propertyResolver = new RelaxedPropertyResolver(env, "spring.datasource.");
    }
}
